// NavBar 组件的业务逻辑函数

export { render } from './html.js';

/**
 * 绑定事件监听器
 * @param {NavBar} component - 组件实例
 */
export function bindEvents(component) {
    // 添加汉堡菜单点击事件
    const menuToggle = component.shadowRoot.getElementById('menuToggle');
    menuToggle?.addEventListener('click', () => toggleMobileMenu());
}

/**
 * 切换移动端菜单
 */
export function toggleMobileMenu() {
    const leftMenu = document.querySelector('left-menu');
    if (leftMenu && leftMenu.shadowRoot) {
        const menuElement = leftMenu.shadowRoot.querySelector('[part="left-menu"]');
        if (menuElement) {
            menuElement.classList.toggle('mobile-open');
        }
    }
}